// import { routeAuthCodes } from '../config/routes';

// export default function access({ codeList }: { codeList: string[] }) {
//   return Object.keys(routeAuthCodes).reduce((result, key) => {
//     const data = { ...result };
//     const code = routeAuthCodes[key];
//     data[code] = (codeList || []).includes(`${code}_VIEW`) || code === routeAuthCodes.GLOBAL;
//     return data;
//   }, {});
// }

// export default function access() {
//   // return Object.keys(routeAuthCodes).reduce((result, key) => {
//   //   const data = { ...result };
//   //   const code = routeAuthCodes[key];
//   //   data[code] = (codeList || []).includes(`${code}_VIEW`) || code === routeAuthCodes.GLOBAL;
//   //   return data;
//   // }, {});
//   return {};
// }

import { routeAuthCodes } from '../config/routes';
import { authSdk } from './utils/auth';
export default function access(params: { codeList: string[] }) {
  return Object.keys(routeAuthCodes).reduce((result, key) => {
    const data = { ...result };
    const code = routeAuthCodes[key];
    data[code] =
      (params?.codeList || []).includes(`${code}_VIEW`) ||
      code === routeAuthCodes.GLOBAL ||
      !authSdk.getAble();
    return data;
  }, {});
}
